<?php 
header('Content-Type:text/html; charset=UTF-8');
$width=100;
$height=50;

$img=imagecreate($width,$height);
$bgColor=imagecolorallocate($img,255,255,255);

$yzm="";
$zfc = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';  
for($i=0;$i<4;$i++){
$rand=$zfc[rand(0,strlen($zfc)-1)];
$yzm.=$rand;
}

$fgColor=imagecolorallocate($img,255,0,0);

$isgo=0;
while ( $isgo<= 50) {
    $x=rand(1,$width-1);
    $y=rand(1,$height-1);
    $red=rand(0,255);
    $green=rand(0,255);
    $blue=rand(0,255);
    $tempColor=imagecolorallocate($img,$red,$green,$blue);

    if($isgo%5==0){
        $x2=rand(1,$width-1);
        $y2=rand(1,$height-1);
        imageline($img, $x, $y, $x2, $y2, $tempColor);
    }

    imagestring($img, 1, $x, $y, '.', $tempColor);
    $isgo++;
}

imagefttext($img, 25, 10, 15, 45, $fgColor, "../web/fonts/couri.ttf", $yzm);

//imagestring($img, 5, 5, 5, $yzm, $fgColor);


header('Content-Type:image/png;');
imagepng($img);
session_start();
$_SESSION['yzm'] = $yzm;
?>
